#ifndef SERVER_PLUGINS_MPTIMETRIGGER_H
#define SERVER_PLUGINS_MPTIMETRIGGER_H

#include "../../Base/lib/bitstring.h"
#include "../../Base/lib/lib.dlt.h"

#ifdef	__cplusplus
extern "C"
{
#endif

#define	FIRST_MINUTE	0
#define	LAST_MINUTE	59
#define	MINUTE_COUNT   (LAST_MINUTE - FIRST_MINUTE + 1)

#define	FIRST_HOUR	0
#define	LAST_HOUR	23
#define	HOUR_COUNT	(LAST_HOUR - FIRST_HOUR + 1)

#define	FIRST_DOM	1
#define	LAST_DOM	31
#define	DOM_COUNT	(LAST_DOM - FIRST_DOM + 1)

#define	FIRST_MONTH	1
#define	LAST_MONTH	12
#define	MONTH_COUNT	(LAST_MONTH - FIRST_MONTH + 1)

#define	FIRST_DOW	0
#define	LAST_DOW	7
#define	DOW_COUNT	(LAST_DOW - FIRST_DOW + 1)


/*
 * Macros for objType
 */
#define OBJ_FLOW 0
#define OBJ_TASK 1

typedef struct triggerObject{
	//char *queue;
	short objType;

	/*void pointer pointed to the object which has been associated with this timeEnry.
	 *
	 */
	void *objAssociate;
}triggerObject;

typedef struct builtInDays{
	bitstr_t	bit_decl(dom,    DOM_COUNT);
	bitstr_t	bit_decl(month,  MONTH_COUNT);
	bitstr_t	bit_decl(dow,    DOW_COUNT);
<<<<<<< .mine
=======

>>>>>>> .r94
	char *name;
	char *description;
	int *mon;
	char *dayRanges;
	char *year;
}builtInDays;

extern  builtInDays *indays;

typedef struct timeExEntry{
	builtInDays *indays;
}timeExEntry;

typedef struct triggerTime{
	bitstr_t	bit_decl(minute, MINUTE_COUNT);
	bitstr_t	bit_decl(hour,   HOUR_COUNT);
	bitstr_t	bit_decl(dom,    DOM_COUNT);
	bitstr_t	bit_decl(month,  MONTH_COUNT);
	bitstr_t	bit_decl(dow,    DOW_COUNT);
}triggerTime;

typedef struct timeTriggerEntry{

	triggerObject *trigerObjs;
	triggerTime *tTimes;
	timeExEntry *texTimes;

}timeTriggerEntry;


/*
 *  The function will return TRUE if it succeeds. Otherwise,
 *  FALSE will be returned and a log message will be appended to the log file.
 */
int addTimeTrigger(timeTriggerEntry *tre);

/**/
triggerObject* pukeTriggeredEventObj();

/*
 * The queue that contains all timeTriggers. The queue is a queue with orders. objects with
 * higher "nice" value of  will be placed in the first positions.
 */

extern dLinkList *qpuke;

/* The function will run as a independent thread.
 * */
void runTriggerEventCycle();

#ifdef	__cplusplus
}
#endif
#endif
